const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './src/js/index.js',
  output: {
    filename: '[name].js',
    path: resolve(__dirname, 'build'),
  },
  module: {
    rules: [
      // loader配置
      {
        test: /\.css$/,
        //多个loader用use
        use: ['style-loader', 'css-loader']
      },
      {
        test: /\.js$/,
        //单个loader用loader
        exclude: /node_modules/,
        // 只检查src下的js文件
        include: resolve(__dirname, 'src'),
        // pre优先执行 post延后执行，不写中间执行
        enforce: 'pre',
        loader: 'eslint-loader',
        // 单个loader可指定options选项
        options: {

        }
      },
      {
        // 一下配置只会生效一个
        oneOf: [

        ]
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html',
      minify: {
        collapseWhitespace: true,
        removeComments: true
      }
    }),
  ],
  mode: 'development',
  
}
